<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>病历管理</title>
    <script src="../resource/js/jquery-1.11.1.min.js"></script>
    <?php PrintPageHead(); ?>
</head>
<body>
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<link href="../resource/css/hermes.css" rel="stylesheet">
<link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
<script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
<script src="../resource/js/hermes.js"></script>

<style type="text/css">
    .form_d{
        margin: 20px ;
    }
</style>
<!-- 配置文件 -->
<script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="../ueditor/ueditor.all.min.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container', {
        toolbars: [
            [  'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'insertorderedlist',
                '|',
                'simpleupload', 'emotion']
        ],
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
    var ue = UE.getEditor('containers', {
        toolbars: [
            [  'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'insertorderedlist',
                '|',
                'simpleupload', 'emotion']
        ],
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
//关闭窗口
    function closeWind(){
        if(typeof(WeixinJSBridge)=='undefined')
            window.close();
        else
            WeixinJSBridge.invoke('closeWindow',{},function(res){
                return true;
            });
    }
</script>
<style>
    .banes {
        width: 90%;
        margin: 10px auto;
    }
    #banas{
        width:33%; float: left;
    }
    #bana{
        width:33%; float: left;
        background-color:#00a2d4;
        color: #ffffff;
    }
    .calendar{
        z-index:999999;
    }
</style>
<?php
global $openId;
$openId=getCurrentUserOID();//id
$bm=new CUI数据中心(Page::m卖家中心_账目,$openId);
$店铺id = $bm->获取所属店铺id($_SESSION['vo用户数据']['id']);
$主治医师id = $_SESSION['vo用户数据']['id'];
//提交之后回到本页面的链接
$病历详情1 = $bm->生成有效链接('Seller15record',$_GET['state']);
//查询该病历的详细信息
$do病历 = new Do病历();
$id = $_GET['id'];
$arr = pdo()->selectOne("select a.*,b.床号 from 病历 as a inner join 床位 as b  on a.床位id = b.id  where a.id = $id and a.店铺id = $店铺id ");
$sql = "select *  from 床位 where 店铺id = $店铺id and 病历id = 0 or id =".$arr['床位id'];
$床位列表 = pdo()->selectAll($sql);
//var_dump($床位列表);
?>
<div class="container-fluid">
    <!--    <h2 class="text-center bg-primary">--><?//=$pageTitle?><!--</h2>-->
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title">修改病历</h3></div>
        <div class="panel-body"></div>
        <div class="panel-body">
            <form class="form-horizontal"   action="../commit.php" method="post" enctype="multipart/form-data" onsubmit="return checkdata()">
                <div class="form-group has-feedback has-success">
                    <label for="nickName" class="col-md-3 control-label text-right ">住院号</label>
                    <div class="col-md-9">
                        <input type='text' class="form-control" name="title" id="title"    value="<?=$arr['title']?>">
                        <span class="glyphicon glyphicon-star form-control-feedback"></span>
                    </div>
                </div>

                <div class="form-group has-feedback has-success">
                    <label for="nickName" class="col-md-3 control-label text-right ">病历号</label>
                    <div class="col-md-9">
                        <input type='text' class="form-control" name="姓名" id="title"   value="<?=$arr['姓名']?>">
                        <span class="glyphicon glyphicon-star form-control-feedback"></span>
                    </div>
                </div>

                <div class="form-group has-feedback has-success">
                    <label for="sellerName" class="col-md-3 control-label text-right ">病人图片</label>
                    <div class="col-md-9">
                       <img src="../<?=$arr['照片']?>" width="50%"/>
                    </div>
                </div>

                <div class="form-group has-feedback has-success">
                    <label for="sellerName" class="col-md-3 control-label text-right ">床位</label>
                    <div class="col-md-9">
                        <select name="床位id">
                            <option value="0" >不住院</option>
                            <?php foreach($床位列表 as $v){?>
                                <option <?php if($v['id'] == $arr['床位id']) echo 'selected="selected"';?> value="<?=$v['id']?>"><?=$v['床号']?></option>
                            <?php }?>
                        </select>
                    </div>
                </div>

                <div class="form-group has-feedback has-success">
                    <label for="description" class="col-md-3 control-label text-right ">病历详情</label>
                    <div class="form_d" style="width:90%;float: right">
                        <textarea id="container" name="content"><?=$arr['详情']?></textarea>
                    </div>
                </div>

                <div class="form-group has-feedback has-success" style="width: 56%; ">
                    <label for="description" class="col-md-3 control-label text-right ">日期</label>
                    <div class="col-md-9" >
                        <input type="text" class="form-control" name="stimes" placeholder="开始日期" id="stimes" value="<?=Date('Y年m月d日')?>" readonly>
                    </div>
                </div>

                <div class="form-group has-feedback has-success">
                    <label for="description" class="col-md-3 control-label text-right ">最新情况</label>
                    <div class="form_d" style="width:90%;float: right">
                        <textarea id="containers" name="contents"></textarea>
                    </div>
                </div>
                <div class="form-group has-feedback has-success" style="width: 56%; float: left">
                    <label for="sellerName" class="col-md-3 control-label text-right ">住院日期</label>
                    <div class="col-md-9">
                        <input type="text" class="form-control" name="stime" placeholder="开始日期" id="stime" value="<?=Date('Y-m-d')?>" readonly>
                    </div>
                </div>

                <input type="hidden" name="businessFlag" value="修改病历">
                <input type="hidden" name="店铺id" value="<?=$店铺id?>">
                <input type="hidden" name="主治医师id" value="<?=$主治医师id?>">
                <input type="hidden" name="病历id" value="<?=$_GET['id']?>">
                <input type="hidden" name="旧床位id" value="<?=$arr['床位id']?>">
                <input type="hidden" name="病历详情1" value="<?=$病历详情1."&id=".$id?>">
                <div class="form-group text-center" style=" width: 100%; float: left">
                    <button type="submit" id="tijiao" class="btn btn-lg btn-success ">&nbsp;&nbsp;修  该&nbsp;&nbsp;</button>
                    <button type="button" id="guanbi" class="btn btn-lg btn-success" onclick="closeWind();">&nbsp;&nbsp;关  闭&nbsp;&nbsp;</button>
                </div>
        </div>

    </div>

</div>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->


<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script>
    //时间控件
    Calendar.setup({
        inputField : "stime",
        ifFormat : "%Y-%m-%d",
        showsTime : "true",
        timeFormat : "24"
    });
    Calendar.setup({
        inputField : "stimes",
        ifFormat : "%Y年%m月%d日",
        showsTime : "true",
        timeFormat : "24"
    });



    function checkdata() {
        var title = $('input[name="title"]').val();
        var stime = $('input[name="stime"]').val();
        var stimes = $('input[name="stimes"]').val();
        if($.trim(title)=='') {
            alert('住院号不能为空!');
            $('input[name="title"]').focus();
            return false;
        }

        if(stime == '') {
            alert('开始日期不能为空!');
            return false;
        }


        var arrStart = stime.split("-");
        var tmpIntStartYear = parseInt(arrStart[0],10);
        var tmpIntStartMonth = parseInt(arrStart[1],10);
        var tmpIntStartDay = parseInt(arrStart[2],10);

        $('#tijiao').attr('disabled','disabled');
        $('#guanbi').attr('disabled','disabled');
    }
</script>
</body>
</html>